home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Source Code / C++ / Applications / CheckBook 2.1d1 / Sources / MAccMan.cp < prev    next >
Encoding:
Text File  |  1995-11-25  |  4.1 KB  |  106 lines  |  [TEXT/MPS ]

  1.  <UScroller.h>
  2. #include <USynchScroller.h>
  3.  
  4. TApp    *gApp;            // Application object
  5.  
  6. //----------------------------------------------------------------------------------------
  7. // main: 
  8. //----------------------------------------------------------------------------------------
  9. #ifndef __MWERKS__
  10. #pragma push
  11. #pragma processor 68000
  12. #endif
  13.  
  14. #pragma segment Main
  15. static TApp* InitWithSplashScreen();
  16.  
  17. static DialogPtr gSplashDlog = 0;    // used during startup
  18.  
  19. void main ()
  20. {
  21.     InitUMacApp_Step1();                                // calls InitToolBox, ValidateConfiguration
  22.     InstallFailureHandler;                                // Install permanent outermost Failure handler
  23.                                                         // This MUST be called from main on PowerPC!
  24.  
  25.     PullApplicationToFront();                             // Pull app to front under MultiFinderâ„¢ 
  26.  
  27.     gApp = InitWithSplashScreen();
  28.     gApp->Run();
  29.  
  30. } // main 
  31.  
  32. TApp* InitWithSplashScreen()
  33. {
  34.     // To avoid heap fragmentation, we allocate space for the DialogRecord on the stack,
  35.     // as a local variable in this procedure, so that the dialog record WON'T be allocated
  36.     // as a non-relocatable block at the bottom of the heap. If we were to pass NULL to
  37.     // GetNewCenteredDialog for the dStorage, then the call to GetNewDialog would allocate
  38.     // the dialog record as a non-relocatable block at the bottom of the heap leading to
  39.     // heap fragmentation during InitUMacApp_Step3's call to MoreMasters.
  40.  
  41.     TApp*    aApp = NULL;
  42.     DialogRecord        theDialogRecord;                // allocated on the stack 
  43.  
  44.     unsigned long startTicks = TickCount();
  45.     const unsigned long kSplashDurationTicks = 2 * 60;    // how long to show the splash screen
  46.     
  47.     if (GetNewCenteredDialog(kSplashDialogID, (Ptr) &theDialogRecord, (WindowPtr) (-1)) != NULL)
  48.     {
  49.         ::SetPort((DialogPtr)&theDialogRecord);
  50.         TextFont(geneva);
  51.         TextSize(9);
  52.         Str255    shortVersionStr;
  53.         Str255    longVersionStr;
  54.         
  55.         if(::GetVersionString(shortVersionStr, longVersionStr) == noErr)
  56.         #if __POWERPC__
  57.             ::ParamText(longVersionStr, "\pPowerPC code now executing.", "\p", "\p");
  58.         #else
  59.             ::ParamText(longVersionStr, "\p680x0 code now executing.", "\p", "\p");
  60.         #endif
  61.         
  62.         ::ShowWindow((DialogPtr)&theDialogRecord);
  63.         ::DrawDialog((GrafPort*) &theDialogRecord);        // Show splash screen 
  64.     }
  65.     // Continue with remainder of initialization 
  66.     
  67.     InitUMacApp_Step3(16);                                // Initialize memory (formerly InitUMacApp)
  68. //    InitUEditionDocument();
  69.     InitUTEView();
  70.     InitUDialog();            // Initialize the dialog unit
  71.     InitUGridView(); 
  72.     InitUPrinting();
  73.  
  74.     MA_REGISTER_CLASS(TMainWindow);
  75.     MA_REGISTER_CLASS(TTransactionListView);
  76.     MA_REGISTER_CLASS(THeadingView);
  77.     MA_REGISTER_CLASS(TEditTransWindow);
  78.     MA_REGISTER_CLASS(TPrimaryScroller);
  79.     MA_REGISTER_CLASS(TSecondaryScroller);
  80.     MA_REGISTER_CLASS(TAboutWindow);
  81.     MA_REGISTER_CLASS(TThermView);
  82.     MA_REGISTER_CLASS(TImporter);
  83.     MA_REGISTER_CLASS(TPuffGreyAdorner);
  84.     
  85.     aApp = new TApp;
  86.     aApp->IApp();
  87.     
  88.     // delay 2 seconds so they can read the splash screen on faster machines!
  89.     
  90.     while(TickCount() < (startTicks + kSplashDurationTicks))
  91.         ;
  92.     
  93.     CloseDialog((DialogPtr) &theDialogRecord);            // Remember to remove the splash screen
  94.     DisposeIfHandle(theDialogRecord.items);
  95.     
  96.     return aApp;
  97.     
  98. } // InitWithSplashScreen 
  99.  
  100.  
  101. #ifndef __MWERKS__
  102. #pragma pop
  103. #endif
  104.  
  105. #pragma segment Inline
  106.